package com.me.batm.models;

import com.badlogic.gdx.math.Circle;
import com.badlogic.gdx.math.Rectangle;
import com.badlogic.gdx.math.Vector2;

public class Aura extends GameEntity{
	protected float radio;
	protected float centerX;
	protected float centerY;
	
	
	public Aura(int direction, float x, float y, float width, float height, Vector2 speed, float velocity, float radio) {
		super(direction, x, y, width, height, speed, velocity);
		this.centerX = x + width / 2;
		this.centerY = y + height / 2;
		this.radio = radio;
		this.collided = false;
		
	}

	public float getRadio() {
		return radio;
	}

	public void setRadio(float radio) {
		this.radio = radio;
	}


	public void setX(float x) {
		this.centerX = x;
	}

	public void setY(float y) {
		this.centerY = y;
	}

	@Override
	public void applyEffectOverPlayer(Player player) {
	}

	@Override
	public void removeEffectOverPlayer(Player player) {
	}
	@Override
	public void move(float delta) {
		
	}

	@Override
	public boolean isColliding(GameObject object) {
		// TODO Auto-generated method stub
		//TODO Implement a more precise intersection method
		Rectangle rectangle = object.shape;
		if (new Circle(centerX, centerY, radio).contains(rectangle.x, rectangle.y)) {
			if (!this.collided) {
				this.collided = true;
				if (object instanceof  Player) {
					applyEffectOverPlayer((Player) object);	
				}
			}
			return true;
		} else {
			if (this.collided) {
				this.collided = false;
//				System.out.println(object.getClass());
				if (object instanceof Player) {
					removeEffectOverPlayer((Player) object);
				}
				
			}
			return false;
		}
		
	}
	
}
